feat: Add skeleton loading support to table#4583
Conversation
6681d62 to
465f073
Compare
465f073 to
58e6f84
Compare
58e6f84 to
14ad9b9
Compare
14ad9b9 to
fa974ca
Compare
fa974ca to
b98f8db
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4583 +/- ##
=======================================
Coverage 97.50% 97.50%
=======================================
Files 947 948 +1
Lines 30248 30262 +14
Branches 11021 11027 +6
=======================================
+ Hits 29493 29507 +14
Misses 708 708
Partials 47 47 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
b98f8db to
290be8c
Compare
290be8c to
99a42fb
Compare
99a42fb to
822f331
Compare
822f331 to
69c7893
Compare
362e123 to
03018d3
Compare
03018d3 to
ae6d4fa
Compare
ae6d4fa to
00a8498
Compare
| </td> | ||
| </tr> | ||
| {Array.from({ length: skeleton.totalRows }, (_, rowIndex) => ( | ||
| <SkeletonRow |
There was a problem hiding this comment.
This block and the one below look similar and have a lot in common, can we extract them to avoid repetetion.
| {Array.from({ length: Math.max(0, skeleton.totalRows - allItems.length) }, (_, rowIndex) => ( | ||
| <SkeletonRow | ||
| key={`skeleton-row-${rowIndex}`} | ||
| rowIndex={rowIndex + 1} |
There was a problem hiding this comment.
I don't understand 1 here to the rowIndex?
There was a problem hiding this comment.
updated the naming so it's clearer what's going on
| resizableColumns, | ||
| colIndexOffset, | ||
| }: SkeletonRowProps) { | ||
| const isFirstRow = rowIndex === 0; |
There was a problem hiding this comment.
Following up: https://github.com/cloudscape-design/components/pull/4583/changes#r3379168550
If we do the +1 to row index then I think this would not be true
There was a problem hiding this comment.
it can be true in the other code path (when only skeleton rows are displayed), but have updated naming so hopefully the logic is clearer now
Add skeleton prop ({ totalRows: number }) that renders skeleton placeholder
rows to fill the table while data is loading.
- skeleton.totalRows defines total visible rows (typically page size)
- Skeleton rows rendered = max(0, totalRows - items.length)
- Standard loading: items=[] + loading=true + skeleton -> all skeleton rows
- Progressive loading: items=[partial] + skeleton -> real rows + trailing skeleton
- A11y: visually-hidden row with ScreenreaderOnly loadingText before skeleton rows
- Skeleton rows use aria-hidden=true
- Includes interactive demo pages for both patterns
00a8498 to
ff19e2c
Compare
Add skeleton prop ({ totalRows: number }) that renders skeleton placeholder rows to fill the table while data is loading.
Description
Related links, issue #, if available: n/a
How has this been tested?
Review checklist
The following items are to be evaluated by the author(s) and the reviewer(s).
Correctness
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.